package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.list.ListFeignClient;
import com.atguigu.gmall.model.list.SearchParam;
import com.atguigu.gmall.model.vo.GoodsSearchResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/9/7 1:01
 */
@Controller
public class ListController {
    @Autowired
    private ListFeignClient listFeignClient;
    @GetMapping("/list.html")
    public String list(SearchParam searchParam, Model model){
        Result<GoodsSearchResultVo> goodsSearchResultVoResult = listFeignClient.searchResult(searchParam);
        GoodsSearchResultVo goodsSearchResultVo = goodsSearchResultVoResult.getData();
        model.addAttribute("searchParam", goodsSearchResultVo.getSearchParam());
        model.addAttribute("trademarkParam", goodsSearchResultVo.getTrademarkParam());
        model.addAttribute("propsParamList", goodsSearchResultVo.getPropsParamList());
        model.addAttribute("trademarkList", goodsSearchResultVo.getTrademarkList());
        model.addAttribute("attrsList", goodsSearchResultVo.getAttrsList());
        model.addAttribute("orderMap", goodsSearchResultVo.getOrderMap());
        model.addAttribute("urlParam", goodsSearchResultVo.getUrlParam());
        model.addAttribute("goodsList", goodsSearchResultVo.getGoodsList());
        model.addAttribute("pageNo", goodsSearchResultVo.getPageNo());
        model.addAttribute("totalPages", goodsSearchResultVo.getTotalPages());
        return "list/index";
    }
}
